package com.smart.web.controller.system;

import com.smart.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.system.domain.EmployeeTrajectory;
import com.smart.system.service.IEmployeeTrajectoryService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 员工移动轨迹Controller
 * 
 * @author smart
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/system/trajectory")
@Api(tags = "员工移动轨迹")
public class EmployeeTrajectoryController extends BaseController
{
    @Autowired
    private IEmployeeTrajectoryService employeeTrajectoryService;

    /**
     * 查询员工移动轨迹列表
     */
    @ApiOperation(value = "查询员工移动轨迹列表")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:list')")
    @GetMapping("/list")
    public TableDataInfo<EmployeeTrajectory> list(EmployeeTrajectory employeeTrajectory)
    {
        startPage();
        List<EmployeeTrajectory> list = employeeTrajectoryService.selectEmployeeTrajectoryList(employeeTrajectory);
        return getDataTable(list);
    }

    /**
     * 导出员工移动轨迹列表
     */
    @ApiOperation(value = "导出员工移动轨迹列表")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:export')")
    @Log(title = "员工移动轨迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmployeeTrajectory employeeTrajectory)
    {
        List<EmployeeTrajectory> list = employeeTrajectoryService.selectEmployeeTrajectoryList(employeeTrajectory);
        ExcelUtil<EmployeeTrajectory> util = new ExcelUtil<EmployeeTrajectory>(EmployeeTrajectory.class);
        util.exportExcel(response, list, "员工移动轨迹数据");
    }

    /**
     * 获取员工移动轨迹详细信息
     */
    @ApiOperation(value = "获取员工移动轨迹详细信息")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:query')")
    @GetMapping(value = "/{id}")
    public R<EmployeeTrajectory> getInfo(@PathVariable("id") String id)
    {
        return R.ok(employeeTrajectoryService.selectEmployeeTrajectoryById(id));
    }

    /**
     * 新增员工移动轨迹
     */
    @ApiOperation(value = "新增员工移动轨迹")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:add')")
    @Log(title = "员工移动轨迹", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Integer> add(@RequestBody EmployeeTrajectory employeeTrajectory)
    {
        return R.ok(employeeTrajectoryService.insertEmployeeTrajectory(employeeTrajectory));
    }

    /**
     * 修改员工移动轨迹
     */
    @ApiOperation(value = "修改员工移动轨迹")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:edit')")
    @Log(title = "员工移动轨迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Integer> edit(@RequestBody EmployeeTrajectory employeeTrajectory)
    {
        return R.ok(employeeTrajectoryService.updateEmployeeTrajectory(employeeTrajectory));
    }

    /**
     * 删除员工移动轨迹
     */
    @ApiOperation(value = "删除员工移动轨迹")
    //@PreAuthorize("@ss.hasPermi('system:trajectory:remove')")
    @Log(title = "员工移动轨迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable String[] ids)
    {
        return R.ok(employeeTrajectoryService.deleteEmployeeTrajectoryByIds(ids));
    }
}
